package com.ytjj.qmyx.supplychain.api.consumer;

import com.rabbitmq.client.Channel;
import com.ytjj.qmyx.supplychain.common.constants.QueueConstants;
import com.ytjj.qmyx.supplychain.service.ExpressOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 
 * 
 **/
@Slf4j
@Component
@RefreshScope
public class ExpressOrderListener {
    @Resource
    private ExpressOrderService expressOrderService;

    @RabbitListener(queuesToDeclare = @Queue(value = QueueConstants.QUERY_ORDEREXPRESS, durable = "true"))
    public void appActivation(String expressId, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag, Channel channel) {
        log.info("收到一条消息query_orderexpress消息：" + expressId + "");
        expressOrderService.updateExpressInfo(Integer.parseInt(expressId));
    }

}
